home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / doc / sigprc12 < prev    next >
Text File  |  1997-07-08  |  1KB  |  35 lines

  1. ; This batch file creates a plot a bandstop filter which suppresses
  2. ; frequencies between 7 cycles per second and 15 cycles per second for
  3. ; data sampled every 0.02 seconds, using the Hanning window. It is used
  4. ; in Chapter 13, "Signal Processing", of _Using IDL_.
  5.  
  6. @sigprc01.bat ; compute time data sequence u
  7.  
  8. ; Compute the kaiser filter coefficients:
  9.  
  10. delt = 0.02 ; sampling period in seconds
  11. f_low = 15. ; frequencies above f_low will be passed
  12. f_high = 7. ; frequencies below f_high will be passed
  13. a_ripple = 50. ; ripple amplitude will be less than -50 dB
  14. nterms = 40 ; the order of the filter
  15.  
  16. ; Compute the impulse response = the filter coefficients
  17.  
  18. bs_ir_k = DIGITAL_FILTER(f_low*2*delt, f_high*2*delt, a_ripple, nterms)
  19.  
  20. u_filt = BLK_CON(bs_ir_k, u) ; convolve the Kaiser filter with the signal
  21.  
  22. v = FFT(u) ; spectrum of original signal
  23.  
  24. v_filt = FFT(u_filt) ; spectrum of filtered signal
  25.  
  26. ; log-log plot of power spectra
  27.  
  28. f = FINDGEN(N/2+1) / (N*delt) ; f = [0.0, 1.0/(N*delt), ... , 1.0/(2.0*delt)]
  29.  
  30. PLOT, f, ABS(v(0:N/2))^2, YTITLE='Power Spectrum', /YLOG, $
  31.    XTITLE='Frequency in cycles / second', /XLOG, $
  32.    XRANGE=[1.0,1.0/(2.0*delt)], XSTYLE=1, $
  33.    TITLE='Spectrum of u(k) Before (solid) and!CAfter (dashed) Digital Filtering'
  34. OPLOT, f, ABS(v_filt(0:N/2))^2, LINESTYLE=2
  35.